import sys
import os

ori_dir = sys.argv[1]
flist = os.listdir(ori_dir)
print(ori_dir)
for f in flist:
	path = os.path.join(ori_dir, f)
	if os.path.isdir(path):
		print(path)
		subflist = os.listdir(path)
		for subf in subflist:
			cdir = os.path.basename(path)
			subpath = os.path.join(path, subf)
			if os.path.isdir(subpath) and subf==cdir:
				print(subpath)
				trdflist = os.listdir(subpath)
				for trdf in trdflist:
					trdpath = os.path.join(subpath, trdf)
					if not os.path.isdir(trdpath):
						cdir = os.path.basename(subpath)
						nf = f"{cdir}-{trdf}"
						new_path = os.path.join(subpath, nf)
						print(f'{trdpath} -> {new_path}')
						os.rename(trdpath, new_path)